<template>
  <div id="pagination">
    <el-pagination
      :current-page="currentPage"
      :page-size="10"
      background
      layout="total, sizes, prev, pager, next, jumper"
      :total="totalNum"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
export default {
  name: 'Pagination',
  props: {
    totalNum: {
      type: Number, // 添加类型定义
      required: true // 根据需求设置是否必填
    },
    currentPage: {
      type: Number, // 添加类型定义
      required: true // 根据需求设置是否必填
    }
  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      this.$emit('handlePageSizeChange', val)
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.$emit('handleCurrentChange', val)
    }
  }
}
</script>

<style scoped>
#pagination {
  text-align: center;
  padding: 20px;
}
</style>
